import axios from 'axios';
exports.GET = (req: any, res: any) => {
    const { type, name } = res;
    // 默认随机歌曲
    let mp3Url =
    'https://c.y.qq.com/v8/fcg-bin/fcg_v8_toplist_cp.fcg?g_tk=5381&uin=0&format=json&inCharset=utf-8&outCharset=utf-8¬ice=0&platform=h5&needNewCode=1&tpl=3&page=detail&type=top&topid=36&_=1520777874472';
    switch (type) {
    // top100
    case '1':
        mp3Url =
        'https://c.y.qq.com/v8/fcg-bin/fcg_v8_toplist_cp.fcg?g_tk=5381&uin=0&format=json&inCharset=utf-8&outCharset=utf-8¬ice=0&platform=h5&needNewCode=1&tpl=3&page=detail&type=top&topid=27&_=1519963122923';
        break;
    case '2':
        mp3Url =
        'https://c.y.qq.com/soso/fcgi-bin/client_search_cp?aggr=1&cr=1&flag_qc=0&p=1&n=30&w=' + name;
        break;
    default:
        break;
    }
    axios.get(mp3Url).then((data) => {
        res.send({
            code: 200,
            message: 'success',
            data: data.data
        });
    });
};
